import Vue from 'vue'
import Vuex from 'vuex'
import utils from '@/utils/utils'
Vue.use(Vuex)

const store = new Vuex.Store({
    state: {
		nowOrgLv:'gk',
		hasLogin: false,
		showErrorModal: false, // 是否显示共通错误弹框
		errorTitle: "",
		errorText: "",
		showLoading: false, // 是否显示loading,
        wxLoginFlg: false,
		carCount:0,
		//imgUrl: utils.fileLoadUrl(),
		imgUrl: "",
		dictDataAll: {},
		regionData:[],
		loginInvalid: false ,// 登录失效
		iconSettings: {}, //图标信息
		spreadInitFlag: false,//开屏初始化flag
		articleDetail:'',// 文章素材内容
		nickName:'',
		headimgurl:'',
		tabbar: [{
			icon: 'iconshouyehome',
			text: "首页"
		}
		, {
			icon: 'icon2',
			text: "全部产品"
		}
		,{
			icon: 'icongouwuche',
			text: "购物车"
		}, {
			icon: 'iconwode',
			text: "个人中心"
		}],
    },
    mutations: {
		setLoginInvalid(state,flg) {
			state.loginInvalid = flg;
		},
		setShowErrorModal(state, showErrorModal) {
			state.showErrorModal = showErrorModal;
		},
		setErrorTitle(state, errorTitle) {
			state.errorTitle = errorTitle;
		},
		setErrorText(state, errorText) {
			state.errorText = errorText;
		},
		changeCarCount(state, carCount) {
			state.carCount = carCount;
		},
		changeDictDataAll(state, dictDataAll) {
			state.dictDataAll = dictDataAll;
		},
		changeRegionData(state, regionData) {
			state.regionData = regionData;
		},
		changeFootBar(state, data) {
			state.tabbar.push(data);
		},
		removeFootBar(state) {
			state.tabbar.splice(4,1);
		},
		setIconSettings(state, iconSettings) {
			state.iconSettings = iconSettings;
		},
		setSpreadInitFlag(state,flag) {
			state.spreadInitFlag = flag;
		},
		setArticleDetail(state,content) {
			state.articleDetail = content;
		},
		setOrgLv(state,orgLv) {
			state.nowOrgLv = orgLv
		},
		setNickName(state,nickName) {
			state.nickName = nickName
		},
		setHeadimgurl(state,headimgurl) {
			state.headimgurl = headimgurl
		}
	}
})

export default store
